package com.ruoyi.terminal.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.terminal.domain.DcTermasgn;
import com.ruoyi.terminal.service.IDcTermasgnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备分配与认领Controller
 * 
 * @author ruoyi
 * @date 2021-02-02
 */
@RestController
@RequestMapping("/asgn")
public class DcTermasgnController extends BaseController
{
    @Autowired
    private IDcTermasgnService dcTermasgnService;

    /**
     * 查询设备分配与认领列表
     */
    @PreAuthorize(hasPermi = "terminal:asgn:list")
    @GetMapping("/list")
    public TableDataInfo list(DcTermasgn dcTermasgn)
    {
        startPage();
        List<DcTermasgn> list = dcTermasgnService.selectDcTermasgnList(dcTermasgn);
        return getDataTable(list);
    }

    /**
     * 获取设备分配与认领详细信息
     */
    @PreAuthorize(hasPermi = "terminal:asgn:query")
    @GetMapping(value = "/{termImei}")
    public AjaxResult getInfo(@PathVariable("termImei") String termImei)
    {
        return AjaxResult.success(dcTermasgnService.selectDcTermasgnById(termImei));
    }

    /**
     * 修改设备分配与认领
     */
    @PreAuthorize(hasPermi = "terminal:asgn:edit")
    @Log(title = "设备分配与认领", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DcTermasgn dcTermasgn)
    {
        return toAjax(dcTermasgnService.updateDcTermasgn(dcTermasgn));
    }

}
